﻿@Html.DevExpress().GridView(
            settings =>
            {
                settings.Name = "gvEditing";
                settings.KeyFieldName = "NSRDZDAH";
                settings.CallbackRouteValues = new { Controller = "Key_NSRXX", Action = "ManagerListPartial" };
                settings.Width = System.Web.UI.WebControls.Unit.Pixel(800);

                //settings.Columns.Add(column =>
                //{
                //    column.Caption = "操作";

                //    column.SetDataItemTemplateContent(c =>
                //    {
                //        Html.DevExpress().HyperLink(s => { s.Name = "linkEdit" + c.VisibleIndex; s.Properties.Text = "修改"; s.ToolTip = "修改"; s.Properties.ImageUrl = Url.Content("~/Content/ControlImages/button_Edit.png"); s.Properties.ClientSideEvents.Click = "function(){TaxPayerManagerEdit('" + DataBinder.Eval(c.DataItem, "NSRDZDAH") + "')}"; s.Style.Add(HtmlTextWriterStyle.Cursor, "pointer"); }).GetHtml();
                //    });
                //    column.Settings.AllowDragDrop = DefaultBoolean.False;
                //    column.Settings.AllowSort = DefaultBoolean.False;

                //    column.Width = 70;
                //});


                settings.Columns.Add(s =>
                {
                    s.Name = "NSRDZDAHstr";
                    s.FieldName = "NSRDZDAHstr";
                    s.Visible = false;
                });
                settings.Columns.Add("NSRBM", "纳税编码");
                settings.Columns.Add("NSRSBH", "纳税识别号");

                settings.Columns.Add("NSRMC", "纳税人名称");
                //settings.Columns.Add("FEnterprisePropName", "企业性质");
                //settings.Columns.Add("FFinancePropName", "资金性质");
                //settings.Columns.Add("GS_NSRSBH", "国税纳税识别号");
                //settings.Columns.Add("GS_NSRMC", "国税纳税人名称");
                //settings.Columns.Add("FDDBRMC", "法人");
                //settings.Columns.Add("DHHM", "电话");
                settings.Columns.Add("SCJYDZ", "地址");
                //settings.Columns.Add("ShowDate", "开户行");
                //settings.Columns.Add("FUpdDateStr", "账号");

                settings.SettingsBehavior.AllowSort = false;
                settings.SettingsBehavior.AllowDragDrop = false;
                settings.SettingsBehavior.AllowSelectByRowClick = false;
                settings.SettingsLoadingPanel.Text = "数据读取中...";
                settings.SettingsBehavior.AllowClientEventsOnLoad = false;
                settings.SettingsBehavior.AllowFocusedRow = true;


                settings.ClientSideEvents.BeginCallback = "function(s,e){OnBeginCallback(s,e)}";

                settings.CommandColumn.Visible = true;
                settings.CommandColumn.ShowSelectCheckbox = true;
                settings.CommandColumn.Width = System.Web.UI.WebControls.Unit.Pixel(5);

                settings.SettingsPager.Position = System.Web.UI.WebControls.PagerPosition.Bottom;
                settings.SettingsPager.FirstPageButton.Visible = true;
                settings.SettingsPager.LastPageButton.Visible = true;
                settings.SettingsPager.PageSize = EnterpriseFund.Common.GlobalConstant.CONSTRING_PAGESIZE;
                settings.SettingsPager.AlwaysShowPager = true;

                settings.CommandColumn.SetHeaderTemplateContent(c =>
                {
                    Html.DevExpress().CheckBox(settingsCheckBox =>
                    {
                        settingsCheckBox.Name = "cbSelectAll";
                        settingsCheckBox.Properties.ClientSideEvents.CheckedChanged = string.Format("function(s, e) {{ if(s.GetChecked()) {0}.SelectAllRowsOnPage(); else {0}.UnselectAllRowsOnPage(); }}", settings.Name);

                        if (c.Grid.VisibleRowCount == 0)
                        {
                            settingsCheckBox.Enabled = false;

                        }
                        else
                        {
                            settingsCheckBox.Checked = c.Grid.VisibleRowCount == c.Grid.Selection.Count;
                        }


                    }).Render();
                });


                settings.PageIndexChanged = (sender, e) =>
                {
                    ASPxGridView grid = (ASPxGridView)sender;
                    grid.Selection.UnselectAll();
                };
                settings.DataBinding = (sender, e) =>
                {
                    ASPxGridView grid = (ASPxGridView)sender;
                    for (int i = 0; i < grid.AllColumns.Count; i++)
                    {
                        if (grid.AllColumns[i].CellStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                        {
                            grid.AllColumns[i].CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                        }
                        if (grid.AllColumns[i].HeaderStyle.HorizontalAlign == System.Web.UI.WebControls.HorizontalAlign.NotSet)
                        {
                            grid.AllColumns[i].HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
                        }
                    }
                };


            }).Bind(Model).GetHtml()